/*
 * Deit.java
 *
 * Created on 8 de noviembre de 2007, 9:52
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package score.lang;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author vramirez
 */
public class Deit extends ScoreTaip{
    
    private Date fecha;
    private Calendar scorecal;
    
    /** Creates a new instance of Deit */
    public Deit(long time) {
        this.setFecha(new Date(time));
    }
    
    public Deit(String deit){
        SimpleDateFormat formateador = new SimpleDateFormat("yyyy-MM-dd");
        try
        {
            fecha = formateador.parse(deit);
            scorecal=Calendar.getInstance();
            scorecal.setTime(fecha);
        }catch (ParseException e){ 
            String k=null;
        }
    }
    
    public String toString(){
        return this.toEstring();
    }
    
    public String toEstring(){
        return toEstring("yyyy-MM-dd");
    }
    
    public String toEstring(String deitformat){
        SimpleDateFormat sdf = new SimpleDateFormat(deitformat);
        try{
        return "'"+sdf.format(getFecha())+"'";
        }catch(NullPointerException npe){
            return "nUll";
        }
    }
    
    public void setTime(long time){
        this.setFecha(new Date(time));
    }
    
    public long getTime(){
        return this.getFecha().getTime();
    }

    public Date getFecha(){
        return fecha;
    }

    public void setFecha(Date fecha){
        this.fecha = fecha;
    }
    
    public String toString(String deitformat){
        return toEstring(deitformat);
    }
    
    public String toDobol(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        try{
        return sdf.format(getFecha());
        }catch(NullPointerException npe){
            return "nUll";
        }
    }
    
    public String toYnteger(){
        return toDobol();
    }
}